Fix 'browse-url-url-at-point' so that scheme does not duplicate
authorUSAMI Kenta <tadsan@zonu.me>
Sat, 3 Feb 2024 18:20:24 +0000 (03:20 +0900)
committerEli Zaretskii <eliz@gnu.org>
Thu, 8 Feb 2024 12:04:18 +0000 (14:04 +0200)
* lisp/net/browse-url.el (browse-url-url-at-point): Prepend
the default scheme only if no scheme present.  (Bug#68913)

lisp/net/browse-url.el

index 359453ca43345d366e0e5402eb31b1f3a4a002fe..bc2a7db9a8bb8c8a5bc47452dda7d3c8e5e55216 100644 (file)
@@ -688,8 +688,10 @@ websites are increasingly rare, but they do still exist."
 (defun browse-url-url-at-point ()
   (or (thing-at-point 'url t)
       ;; assume that the user is pointing at something like gnu.org/gnu
-      (let ((f (thing-at-point 'filename t)))
-        (and f (concat browse-url-default-scheme "://" f)))))
+      (when-let ((f (thing-at-point 'filename t)))
+       (if (string-match-p browse-url-button-regexp f)
+           f
+         (concat browse-url-default-scheme "://" f)))))
 
 ;; Having this as a separate function called by the browser-specific
 ;; functions allows them to be stand-alone commands, making it easier